1 module directx.dwrite_2; 2 //+-------------------------------------------------------------------------- 3 // 4 // Copyright (c) Microsoft Corporation. All rights reserved. 5 // 6 // Abstract: 7 // DirectX Typography Services public API definitions. 8 // 9 //---------------------------------------------------------------------------- 10 11 version(Windows): 12 version(DirectWrite): 13 14 public import directx.dwrite_1; 15 16 /// <summary> 17 /// How to align glyphs to the margin. 18 /// </summary> 19 alias DWRITE_OPTICAL_ALIGNMENT = int; 20 enum : DWRITE_OPTICAL_ALIGNMENT 21 { 22 /// <summary> 23 /// Align to the default metrics of the glyph. 24 /// </summary> 25 DWRITE_OPTICAL_ALIGNMENT_NONE, 26 27 /// <summary> 28 /// Align glyphs to the margins. Without this, some small whitespace 29 /// may be present between the text and the margin from the glyph's side 30 /// bearing values. Note that glyphs may still overhang outside the 31 /// margin, such as flourishes or italic slants. 32 /// </summary> 33 DWRITE_OPTICAL_ALIGNMENT_NO_SIDE_BEARINGS, 34 } 35 36 37 /// <summary> 38 /// Whether to enable grid-fitting of glyph outlines (a.k.a. hinting). 39 /// </summary> 40 alias DWRITE_GRID_FIT_MODE = int; 41 enum : DWRITE_GRID_FIT_MODE 42 { 43 /// <summary> 44 /// Choose grid fitting base on the font's gasp table information. 45 /// </summary> 46 DWRITE_GRID_FIT_MODE_DEFAULT, 47 48 /// <summary> 49 /// Always disable grid fitting, using the ideal glyph outlines. 50 /// </summary> 51 DWRITE_GRID_FIT_MODE_DISABLED, 52 53 /// <summary> 54 /// Enable grid fitting, adjusting glyph outlines for device pixel display. 55 /// </summary> 56 DWRITE_GRID_FIT_MODE_ENABLED 57 } 58 59 60 /// <summary> 61 /// Overall metrics associated with text after layout. 62 /// All coordinates are in device independent pixels (DIPs). 63 /// </summary> 64 struct DWRITE_TEXT_METRICS1 // : DWRITE_TEXT_METRICS 65 { 66 alias dtm this; 67 DWRITE_TEXT_METRICS dtm; 68 69 /// <summary> 70 /// The height of the formatted text taking into account the 71 /// trailing whitespace at the end of each line, which will 72 /// matter for vertical reading directions. 73 /// </summary> 74 FLOAT heightIncludingTrailingWhitespace; 75 } 76 77 78 /// <summary> 79 /// The text renderer interface represents a set of application-defined 80 /// callbacks that perform rendering of text, inline objects, and decorations 81 /// such as underlines. 82 /// </summary> 83 mixin( uuid!(IDWriteTextRenderer1, "D3E0E934-22A0-427E-AAE4-7D9574B59DB1") ); 84 interface IDWriteTextRenderer1 : IDWriteTextRenderer 85 { 86 /// <summary> 87 /// IDWriteTextLayout::Draw calls this function to instruct the client to 88 /// render a run of glyphs. 89 /// </summary> 90 /// <param name="clientDrawingContext">The context passed to 91 /// IDWriteTextLayout::Draw.</param> 92 /// <param name="baselineOriginX">X-coordinate of the baseline.</param> 93 /// <param name="baselineOriginY">Y-coordinate of the baseline.</param> 94 /// <param name="orientationAngle">Orientation of the glyph run.</param> 95 /// <param name="measuringMode">Specifies measuring method for glyphs in 96 /// the run. Renderer implementations may choose different rendering 97 /// modes for given measuring methods, but best results are seen when 98 /// the rendering mode matches the corresponding measuring mode: 99 /// DWRITE_RENDERING_MODE_CLEARTYPE_NATURAL for DWRITE_MEASURING_MODE_NATURAL 100 /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_CLASSIC for DWRITE_MEASURING_MODE_GDI_CLASSIC 101 /// DWRITE_RENDERING_MODE_CLEARTYPE_GDI_NATURAL for DWRITE_MEASURING_MODE_GDI_NATURAL 102 /// </param> 103 /// <param name="glyphRun">The glyph run to draw.</param> 104 /// <param name="glyphRunDescription">Properties of the characters 105 /// associated with this run.</param> 106 /// <param name="clientDrawingEffect">The drawing effect set in 107 /// IDWriteTextLayout::SetDrawingEffect.</param> 108 /// <returns> 109 /// Standard HRESULT error code. 110 /// </returns> 111 /// <remarks> 112 /// If a non-identity orientation is passed, the glyph run should be 113 /// rotated around the given baseline x and y coordinates. The function 114 /// IDWriteAnalyzer2::GetGlyphOrientationTransform will return the 115 /// necessary transform for you, which can be combined with any existing 116 /// world transform on the drawing context. 117 /// </remarks> 118 HRESULT DrawGlyphRun( 119 void* clientDrawingContext, 120 FLOAT baselineOriginX, 121 FLOAT baselineOriginY, 122 DWRITE_GLYPH_ORIENTATION_ANGLE orientationAngle, 123 DWRITE_MEASURING_MODE measuringMode, 124 const(DWRITE_GLYPH_RUN)* glyphRun, 125 const(DWRITE_GLYPH_RUN_DESCRIPTION)* glyphRunDescription, 126 IUnknown clientDrawingEffect 127 ); 128 129 /// <summary> 130 /// IDWriteTextLayout::Draw calls this function to instruct the client to draw 131 /// an underline. 132 /// </summary> 133 /// <param name="clientDrawingContext">The context passed to 134 /// IDWriteTextLayout::Draw.</param> 135 /// <param name="baselineOriginX">X-coordinate of the baseline.</param> 136 /// <param name="baselineOriginY">Y-coordinate of the baseline.</param> 137 /// <param name="orientationAngle">Orientation of the underline.</param> 138 /// <param name="underline">Underline logical information.</param> 139 /// <param name="clientDrawingEffect">The drawing effect set in 140 /// IDWriteTextLayout::SetDrawingEffect.</param> 141 /// <returns> 142 /// Standard HRESULT error code. 143 /// </returns> 144 /// <remarks> 145 /// A single underline can be broken into multiple calls, depending on 146 /// how the formatting changes attributes. If font sizes/styles change 147 /// within an underline, the thickness and offset will be averaged 148 /// weighted according to characters. 149 /// 150 /// To get the correct top coordinate of the underline rect, add 151 /// underline::offset to the baseline's Y. Otherwise the underline will 152 /// be immediately under the text. The x coordinate will always be passed 153 /// as the left side, regardless of text directionality. This simplifies 154 /// drawing and reduces the problem of round-off that could potentially 155 /// cause gaps or a double stamped alpha blend. To avoid alpha overlap, 156 /// round the end points to the nearest device pixel. 157 /// </remarks> 158 HRESULT DrawUnderline( 159 void* clientDrawingContext, 160 FLOAT baselineOriginX, 161 FLOAT baselineOriginY, 162 DWRITE_GLYPH_ORIENTATION_ANGLE orientationAngle, 163 const(DWRITE_UNDERLINE)* underline, 164 IUnknown clientDrawingEffect 165 ); 166 167 /// <summary> 168 /// IDWriteTextLayout::Draw calls this function to instruct the client to draw 169 /// a strikethrough. 170 /// </summary> 171 /// <param name="clientDrawingContext">The context passed to 172 /// IDWriteTextLayout::Draw.</param> 173 /// <param name="baselineOriginX">X-coordinate of the baseline.</param> 174 /// <param name="baselineOriginY">Y-coordinate of the baseline.</param> 175 /// <param name="orientationAngle">Orientation of the strikethrough.</param> 176 /// <param name="strikethrough">Strikethrough logical information.</param> 177 /// <param name="clientDrawingEffect">The drawing effect set in 178 /// IDWriteTextLayout::SetDrawingEffect.</param> 179 /// <returns> 180 /// Standard HRESULT error code. 181 /// </returns> 182 /// <remarks> 183 /// A single strikethrough can be broken into multiple calls, depending on 184 /// how the formatting changes attributes. Strikethrough is not averaged 185 /// across font sizes/styles changes. 186 /// To get the correct top coordinate of the strikethrough rect, 187 /// add strikethrough::offset to the baseline's Y. 188 /// Like underlines, the x coordinate will always be passed as the left side, 189 /// regardless of text directionality. 190 /// </remarks> 191 HRESULT DrawStrikethrough( 192 void* clientDrawingContext, 193 FLOAT baselineOriginX, 194 FLOAT baselineOriginY, 195 DWRITE_GLYPH_ORIENTATION_ANGLE orientationAngle, 196 const(DWRITE_STRIKETHROUGH)* strikethrough, 197 IUnknown clientDrawingEffect 198 ); 199 200 /// <summary> 201 /// IDWriteTextLayout::Draw calls this application callback when it needs to 202 /// draw an inline object. 203 /// </summary> 204 /// <param name="clientDrawingContext">The context passed to 205 /// IDWriteTextLayout::Draw.</param> 206 /// <param name="originX">X-coordinate at the top-left corner of the 207 /// inline object.</param> 208 /// <param name="originY">Y-coordinate at the top-left corner of the 209 /// inline object.</param> 210 /// <param name="orientationAngle">Orientation of the inline object.</param> 211 /// <param name="inlineObject">The object set using IDWriteTextLayout::SetInlineObject.</param> 212 /// <param name="isSideways">The object should be drawn on its side.</param> 213 /// <param name="isRightToLeft">The object is in an right-to-left context 214 /// and should be drawn flipped.</param> 215 /// <param name="clientDrawingEffect">The drawing effect set in 216 /// IDWriteTextLayout::SetDrawingEffect.</param> 217 /// <returns> 218 /// Standard HRESULT error code. 219 /// </returns> 220 /// <remarks> 221 /// The right-to-left flag is a hint to draw the appropriate visual for 222 /// that reading direction. For example, it would look strange to draw an 223 /// arrow pointing to the right to indicate a submenu. The sideways flag 224 /// similarly hints that the object is drawn in a different orientation. 225 /// If a non-identity orientation is passed, the top left of the inline 226 /// object should be rotated around the given x and y coordinates. 227 /// IDWriteAnalyzer2::GetGlyphOrientationTransform returns the necessary 228 /// transform for this. 229 /// </remarks> 230 HRESULT DrawInlineObject( 231 void* clientDrawingContext, 232 FLOAT originX, 233 FLOAT originY, 234 DWRITE_GLYPH_ORIENTATION_ANGLE orientationAngle, 235 IDWriteInlineObject inlineObject, 236 BOOL isSideways, 237 BOOL isRightToLeft, 238 IUnknown clientDrawingEffect 239 ); 240 } 241 242 243 /// <summary> 244 /// The format of text used for text layout. 245 /// </summary> 246 /// <remarks> 247 /// This object may not be thread-safe and it may carry the state of text format change. 248 /// </remarks> 249 mixin( uuid!(IDWriteTextFormat1, "5F174B49-0D8B-4CFB-8BCA-F1CCE9D06C67") ); 250 interface IDWriteTextFormat1 : IDWriteTextFormat 251 { 252 /// <summary> 253 /// Set the preferred orientation of glyphs when using a vertical reading direction. 254 /// </summary> 255 /// <param name="glyphOrientation">Preferred glyph orientation.</param> 256 /// <returns> 257 /// Standard HRESULT error code. 258 /// </returns> 259 HRESULT SetVerticalGlyphOrientation( 260 DWRITE_VERTICAL_GLYPH_ORIENTATION glyphOrientation 261 ); 262 263 /// <summary> 264 /// Get the preferred orientation of glyphs when using a vertical reading 265 /// direction. 266 /// </summary> 267 DWRITE_VERTICAL_GLYPH_ORIENTATION GetVerticalGlyphOrientation(); 268 269 /// <summary> 270 /// Set whether or not the last word on the last line is wrapped. 271 /// </summary> 272 /// <param name="isLastLineWrappingEnabled">Line wrapping option.</param> 273 /// <returns> 274 /// Standard HRESULT error code. 275 /// </returns> 276 HRESULT SetLastLineWrapping( 277 BOOL isLastLineWrappingEnabled 278 ); 279 280 /// <summary> 281 /// Get whether or not the last word on the last line is wrapped. 282 /// </summary> 283 BOOL GetLastLineWrapping(); 284 285 /// <summary> 286 /// Set how the glyphs align to the edges the margin. Default behavior is 287 /// to align glyphs using their default glyphs metrics which include side 288 /// bearings. 289 /// </summary> 290 /// <param name="opticalAlignment">Optical alignment option.</param> 291 /// <returns> 292 /// Standard HRESULT error code. 293 /// </returns> 294 HRESULT SetOpticalAlignment( 295 DWRITE_OPTICAL_ALIGNMENT opticalAlignment 296 ); 297 298 /// <summary> 299 /// Get how the glyphs align to the edges the margin. 300 /// </summary> 301 DWRITE_OPTICAL_ALIGNMENT GetOpticalAlignment(); 302 303 /// <summary> 304 /// Apply a custom font fallback onto layout. If none is specified, 305 /// layout uses the system fallback list. 306 /// </summary> 307 /// <param name="fontFallback">Custom font fallback created from 308 /// IDWriteFontFallbackBuilder::CreateFontFallback or from 309 /// IDWriteFactory2::GetSystemFontFallback.</param> 310 /// <returns> 311 /// Standard HRESULT error code. 312 /// </returns> 313 HRESULT SetFontFallback( 314 IDWriteFontFallback fontFallback 315 ); 316 317 /// <summary> 318 /// Get the current font fallback object. 319 /// </summary> 320 HRESULT GetFontFallback( 321 /*out*/ IDWriteFontFallback* fontFallback 322 ); 323 } 324 325 326 /// <summary> 327 /// The text layout interface represents a block of text after it has 328 /// been fully analyzed and formatted. 329 /// 330 /// All coordinates are in device independent pixels (DIPs). 331 /// </summary> 332 mixin( uuid!(IDWriteTextLayout2, "1093C18F-8D5E-43F0-B064-0917311B525E") ); 333 interface IDWriteTextLayout2 : IDWriteTextLayout1 334 { 335 /// <summary> 336 /// GetMetrics retrieves overall metrics for the formatted string. 337 /// </summary> 338 /// <param name="textMetrics">The returned metrics.</param> 339 /// <returns> 340 /// Standard HRESULT error code. 341 /// </returns> 342 /// <remarks> 343 /// Drawing effects like underline and strikethrough do not contribute 344 /// to the text size, which is essentially the sum of advance widths and 345 /// line heights. Additionally, visible swashes and other graphic 346 /// adornments may extend outside the returned width and height. 347 /// </remarks> 348 HRESULT GetMetrics( 349 /*out*/ DWRITE_TEXT_METRICS1* textMetrics 350 ); 351 352 //using IDWriteTextLayout::GetMetrics; 353 354 /// <summary> 355 /// Set the preferred orientation of glyphs when using a vertical reading direction. 356 /// </summary> 357 /// <param name="glyphOrientation">Preferred glyph orientation.</param> 358 /// <returns> 359 /// Standard HRESULT error code. 360 /// </returns> 361 HRESULT SetVerticalGlyphOrientation( 362 DWRITE_VERTICAL_GLYPH_ORIENTATION glyphOrientation 363 ); 364 365 /// <summary> 366 /// Get the preferred orientation of glyphs when using a vertical reading 367 /// direction. 368 /// </summary> 369 DWRITE_VERTICAL_GLYPH_ORIENTATION GetVerticalGlyphOrientation(); 370 371 /// <summary> 372 /// Set whether or not the last word on the last line is wrapped. 373 /// </summary> 374 /// <param name="isLastLineWrappingEnabled">Line wrapping option.</param> 375 /// <returns> 376 /// Standard HRESULT error code. 377 /// </returns> 378 HRESULT SetLastLineWrapping( 379 BOOL isLastLineWrappingEnabled 380 ); 381 382 /// <summary> 383 /// Get whether or not the last word on the last line is wrapped. 384 /// </summary> 385 BOOL GetLastLineWrapping(); 386 387 /// <summary> 388 /// Set how the glyphs align to the edges the margin. Default behavior is 389 /// to align glyphs using their default glyphs metrics which include side 390 /// bearings. 391 /// </summary> 392 /// <param name="opticalAlignment">Optical alignment option.</param> 393 /// <returns> 394 /// Standard HRESULT error code. 395 /// </returns> 396 HRESULT SetOpticalAlignment( 397 DWRITE_OPTICAL_ALIGNMENT opticalAlignment 398 ); 399 400 /// <summary> 401 /// Get how the glyphs align to the edges the margin. 402 /// </summary> 403 DWRITE_OPTICAL_ALIGNMENT GetOpticalAlignment(); 404 405 /// <summary> 406 /// Apply a custom font fallback onto layout. If none is specified, 407 /// layout uses the system fallback list. 408 /// </summary> 409 /// <param name="fontFallback">Custom font fallback created from 410 /// IDWriteFontFallbackBuilder::CreateFontFallback or 411 /// IDWriteFactory2::GetSystemFontFallback.</param> 412 /// <returns> 413 /// Standard HRESULT error code. 414 /// </returns> 415 HRESULT SetFontFallback( 416 IDWriteFontFallback fontFallback 417 ); 418 419 /// <summary> 420 /// Get the current font fallback object. 421 /// </summary> 422 HRESULT GetFontFallback( 423 /*out*/ IDWriteFontFallback* fontFallback 424 ); 425 } 426 427 428 /// <summary> 429 /// The text analyzer interface represents a set of application-defined 430 /// callbacks that perform rendering of text, inline objects, and decorations 431 /// such as underlines. 432 /// </summary> 433 mixin( uuid!(IDWriteTextAnalyzer2, "553A9FF3-5693-4DF7-B52B-74806F7F2EB9") ); 434 interface IDWriteTextAnalyzer2 : IDWriteTextAnalyzer1 435 { 436 /// <summary> 437 /// Returns 2x3 transform matrix for the respective angle to draw the 438 /// glyph run or other object. 439 /// </summary> 440 /// <param name="glyphOrientationAngle">The angle reported to one of the application callbacks, 441 /// including IDWriteTextAnalysisSink1::SetGlyphOrientation and IDWriteTextRenderer1::Draw*.</param> 442 /// <param name="isSideways">Whether the run's glyphs are sideways or not.</param> 443 /// <param name="originX">X origin of the element, be it a glyph run or underline or other.</param> 444 /// <param name="originY">Y origin of the element, be it a glyph run or underline or other.</param> 445 /// <param name="transform">Returned transform.</param> 446 /// <returns> 447 /// Standard HRESULT error code. 448 /// </returns> 449 /// <remarks> 450 /// This rotates around the given origin x and y, returning a translation component 451 /// such that the glyph run, text decoration, or inline object is drawn with the 452 /// right orientation at the expected coordinate. 453 /// </remarks> 454 HRESULT GetGlyphOrientationTransform( 455 DWRITE_GLYPH_ORIENTATION_ANGLE glyphOrientationAngle, 456 BOOL isSideways, 457 FLOAT originX, 458 FLOAT originY, 459 /*out*/ DWRITE_MATRIX* transform 460 ); 461 462 /// <summary> 463 /// Returns a list of typographic feature tags for the given script and language. 464 /// </summary> 465 /// <param name="fontFace">The font face to get features from.</param> 466 /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param> 467 /// <param name="localeName">The locale to use when selecting the feature, 468 /// such en-us or ja-jp.</param> 469 /// <param name="maxTagCount">Maximum tag count.</param> 470 /// <param name="actualTagCount">Actual tag count. If greater than 471 /// maxTagCount, E_NOT_SUFFICIENT_BUFFER is returned, and the call 472 /// should be retried with a larger buffer.</param> 473 /// <param name="tags">Feature tag list.</param> 474 /// <returns> 475 /// Standard HRESULT error code. 476 /// </returns> 477 HRESULT GetTypographicFeatures( 478 IDWriteFontFace fontFace, 479 DWRITE_SCRIPT_ANALYSIS scriptAnalysis, 480 const(WCHAR)* localeName, 481 UINT32 maxTagCount, 482 /*out*/ UINT32* actualTagCount, 483 /*out*/ DWRITE_FONT_FEATURE_TAG* tags 484 ); 485 486 /// <summary> 487 /// Returns an array of which glyphs are affected by a given feature. 488 /// </summary> 489 /// <param name="fontFace">The font face to read glyph information from.</param> 490 /// <param name="scriptAnalysis">Script analysis result from AnalyzeScript.</param> 491 /// <param name="localeName">The locale to use when selecting the feature, 492 /// such en-us or ja-jp.</param> 493 /// <param name="featureTag">OpenType feature name to use, which may be one 494 /// of the DWRITE_FONT_FEATURE_TAG values or a custom feature using 495 /// DWRITE_MAKE_OPENTYPE_TAG.</param> 496 /// <param name="glyphCount">Number of glyph indices to check.</param> 497 /// <param name="glyphIndices">Glyph indices to check for feature application.</param> 498 /// <param name="featureApplies">Output of which glyphs are affected by the 499 /// feature, where for each glyph affected, the respective array index 500 /// will be 1. The result is returned per-glyph without regard to 501 /// neighboring context of adjacent glyphs.</param> 502 /// </remarks> 503 /// <returns> 504 /// Standard HRESULT error code. 505 /// </returns> 506 HRESULT CheckTypographicFeature( 507 IDWriteFontFace fontFace, 508 DWRITE_SCRIPT_ANALYSIS scriptAnalysis, 509 const(WCHAR)* localeName, 510 DWRITE_FONT_FEATURE_TAG featureTag, 511 UINT32 glyphCount, 512 const(UINT16)* glyphIndices, 513 /*out*/ UINT8* featureApplies 514 ); 515 } 516 517 518 /// <summary> 519 /// A font fallback definition used for mapping characters to fonts capable of 520 /// supporting them. 521 /// </summary> 522 mixin( uuid!(IDWriteFontFallback, "EFA008F9-F7A1-48BF-B05C-F224713CC0FF") ); 523 interface IDWriteFontFallback : IUnknown 524 { 525 /// <summary> 526 /// Determines an appropriate font to use to render the range of text. 527 /// </summary> 528 /// <param name="source">The text source implementation holds the text and 529 /// locale.</param> 530 /// <param name="textLength">Length of the text to analyze.</param> 531 /// <param name="baseFontCollection">Default font collection to use.</param> 532 /// <param name="baseFont">Base font to check (optional).</param> 533 /// <param name="baseFamilyName">Family name of the base font. If you pass 534 /// null, no matching will be done against the family.</param> 535 /// <param name="baseWeight">Desired weight.</param> 536 /// <param name="baseStyle">Desired style.</param> 537 /// <param name="baseStretch">Desired stretch.</param> 538 /// <param name="mappedLength">Length of text mapped to the mapped font. 539 /// This will always be less or equal to the input text length and 540 /// greater than zero (if the text length is non-zero) so that the 541 /// caller advances at least one character each call.</param> 542 /// <param name="mappedFont">The font that should be used to render the 543 /// first mappedLength characters of the text. If it returns NULL, 544 /// then no known font can render the text, and mappedLength is the 545 /// number of unsupported characters to skip.</param> 546 /// <param name="scale">Scale factor to multiply the em size of the 547 /// returned font by.</param> 548 /// <returns> 549 /// Standard HRESULT error code. 550 /// </returns> 551 HRESULT MapCharacters( 552 IDWriteTextAnalysisSource analysisSource, 553 UINT32 textPosition, 554 UINT32 textLength, 555 IDWriteFontCollection baseFontCollection, 556 const(WCHAR)* baseFamilyName, 557 DWRITE_FONT_WEIGHT baseWeight, 558 DWRITE_FONT_STYLE baseStyle, 559 DWRITE_FONT_STRETCH baseStretch, 560 UINT32* mappedLength, 561 /*out*/ IDWriteFont* mappedFont, 562 /*out*/ FLOAT* scale 563 ); 564 } 565 566 567 /// <summary> 568 /// Builder used to create a font fallback definition by appending a series of 569 /// fallback mappings, followed by a creation call. 570 /// </summary> 571 /// <remarks> 572 /// This object may not be thread-safe. 573 /// </remarks> 574 mixin( uuid!(IDWriteFontFallbackBuilder, "FD882D06-8ABA-4FB8-B849-8BE8B73E14DE") ); 575 interface IDWriteFontFallbackBuilder : IUnknown 576 { 577 /// <summary> 578 /// Appends a single mapping to the list. Call this once for each additional mapping. 579 /// </summary> 580 /// <param name="ranges">Unicode ranges that apply to this mapping.</param> 581 /// <param name="rangesCount">Number of Unicode ranges.</param> 582 /// <param name="localeName">Locale of the context (e.g. document locale).</param> 583 /// <param name="baseFamilyName">Base family name to match against, if applicable.</param> 584 /// <param name="fontCollection">Explicit font collection for this mapping (optional).</param> 585 /// <param name="targetFamilyNames">List of target family name strings.</param> 586 /// <param name="targetFamilyNamesCount">Number of target family names.</param> 587 /// <param name="scale">Scale factor to multiply the result target font by.</param> 588 /// <returns> 589 /// Standard HRESULT error code. 590 /// </returns> 591 HRESULT AddMapping( 592 const(DWRITE_UNICODE_RANGE)* ranges, 593 UINT32 rangesCount, 594 const(WCHAR*)* targetFamilyNames, 595 UINT32 targetFamilyNamesCount, 596 IDWriteFontCollection fontCollection = null, 597 const(WCHAR)* localeName = null, 598 const(WCHAR)* baseFamilyName = null, 599 FLOAT scale = 1.0f 600 ); 601 602 /// <summary> 603 /// Appends all the mappings from an existing font fallback object. 604 /// </summary> 605 /// <param name="fontFallback">Font fallback to read mappings from.</param> 606 /// <returns> 607 /// Standard HRESULT error code. 608 /// </returns> 609 HRESULT AddMappings( 610 IDWriteFontFallback fontFallback 611 ); 612 613 /// <summary> 614 /// Creates the finalized fallback object from the mappings added. 615 /// </summary> 616 /// <param name="fontFallback">Created fallback list.</param> 617 /// <returns> 618 /// Standard HRESULT error code. 619 /// </returns> 620 HRESULT CreateFontFallback( 621 /*out*/ IDWriteFontFallback* fontFallback 622 ); 623 } 624 625 /// <summary> 626 /// DWRITE_COLOR_F 627 /// </summary> 628 static if ( !__traits(compiles,D3DCOLORVALUE.sizeof) ) 629 { 630 631 struct D3DCOLORVALUE 632 { 633 union { 634 FLOAT r; 635 FLOAT dvR; 636 } 637 union { 638 FLOAT g; 639 FLOAT dvG; 640 } 641 union { 642 FLOAT b; 643 FLOAT dvB; 644 } 645 union { 646 FLOAT a; 647 FLOAT dvA; 648 } 649 } 650 } 651 652 alias DWRITE_COLOR_F = D3DCOLORVALUE; 653 654 /// <summary> 655 /// The IDWriteFont interface represents a physical font in a font collection. 656 /// </summary> 657 mixin( uuid!(IDWriteFont2, "29748ed6-8c9c-4a6a-be0b-d912e8538944") ); 658 interface IDWriteFont2 : IDWriteFont1 659 { 660 /// <summary> 661 /// Returns TRUE if the font contains color information (COLR and CPAL tables), 662 /// or FALSE if not. 663 /// </summary> 664 BOOL IsColorFont(); 665 } 666 667 /// <summary> 668 /// The interface that represents an absolute reference to a font face. 669 /// It contains font face type, appropriate file references and face identification data. 670 /// Various font data such as metrics, names and glyph outlines is obtained from IDWriteFontFace. 671 /// </summary> 672 mixin( uuid!(IDWriteFontFace2, "d8b768ff-64bc-4e66-982b-ec8e87f693f7") ); 673 interface IDWriteFontFace2 : IDWriteFontFace1 674 { 675 /// <summary> 676 /// Returns TRUE if the font contains color information (COLR and CPAL tables), 677 /// or FALSE if not. 678 /// </summary> 679 BOOL IsColorFont(); 680 681 /// <summary> 682 /// Returns the number of color palettes defined by the font. The return 683 /// value is zero if the font has no color information. Color fonts must 684 /// have at least one palette, with palette index zero being the default. 685 /// </summary> 686 UINT32 GetColorPaletteCount(); 687 688 /// <summary> 689 /// Returns the number of entries in each color palette. All color palettes 690 /// in a font have the same number of palette entries. The return value is 691 /// zero if the font has no color information. 692 /// </summary> 693 UINT32 GetPaletteEntryCount(); 694 695 /// <summary> 696 /// Reads color values from the font's color palette. 697 /// </summary> 698 /// <param name="colorPaletteIndex">Zero-based index of the color palette. If the 699 /// font does not have a palette with the specified index, the method returns 700 /// DWRITE_E_NOCOLOR.<param> 701 /// <param name="firstEntryIndex">Zero-based index of the first palette entry 702 /// to read.</param> 703 /// <param name="entryCount">Number of palette entries to read.</param> 704 /// <param name="paletteEntries">Array that receives the color values.<param> 705 /// <returns> 706 /// Standard HRESULT error code. 707 /// The return value is E_INVALIDARG if firstEntryIndex + entryCount is greater 708 /// than the actual number of palette entries as returned by GetPaletteEntryCount. 709 /// The return value is DWRITE_E_NOCOLOR if the font does not have a palette 710 /// with the specified palette index. 711 /// </returns> 712 HRESULT GetPaletteEntries( 713 UINT32 colorPaletteIndex, 714 UINT32 firstEntryIndex, 715 UINT32 entryCount, 716 /*out*/ DWRITE_COLOR_F* paletteEntries 717 ); 718 719 /// <summary> 720 /// Determines the recommended text rendering and grid-fit mode to be used based on the 721 /// font, size, world transform, and measuring mode. 722 /// </summary> 723 /// <param name="fontEmSize">Logical font size in DIPs.</param> 724 /// <param name="dpiX">Number of pixels per logical inch in the horizontal direction.</param> 725 /// <param name="dpiY">Number of pixels per logical inch in the vertical direction.</param> 726 /// <param name="transform">Specifies the world transform.</param> 727 /// <param name="outlineThreshold">Specifies the quality of the graphics system's outline rendering, 728 /// affects the size threshold above which outline rendering is used.</param> 729 /// <param name="measuringMode">Specifies the method used to measure during text layout. For proper 730 /// glyph spacing, the function returns a rendering mode that is compatible with the specified 731 /// measuring mode.</param> 732 /// <param name="renderingParams">Rendering parameters object. This parameter is necessary in case the rendering parameters 733 /// object overrides the rendering mode.</param> 734 /// <param name="renderingMode">Receives the recommended rendering mode.</param> 735 /// <param name="gridFitMode">Receives the recommended grid-fit mode.</param> 736 /// <remarks> 737 /// This method should be used to determine the actual rendering mode in cases where the rendering 738 /// mode of the rendering params object is DWRITE_RENDERING_MODE_DEFAULT, and the actual grid-fit 739 /// mode when the rendering params object is DWRITE_GRID_FIT_MODE_DEFAULT. 740 /// </remarks> 741 /// <returns> 742 /// Standard HRESULT error code. 743 /// </returns> 744 HRESULT GetRecommendedRenderingMode( 745 FLOAT fontEmSize, 746 FLOAT dpiX, 747 FLOAT dpiY, 748 const(DWRITE_MATRIX)* transform, 749 BOOL isSideways, 750 DWRITE_OUTLINE_THRESHOLD outlineThreshold, 751 DWRITE_MEASURING_MODE measuringMode, 752 IDWriteRenderingParams renderingParams, 753 /*out*/ DWRITE_RENDERING_MODE* renderingMode, 754 /*out*/ DWRITE_GRID_FIT_MODE* gridFitMode 755 ); 756 } 757 758 /// <summary> 759 /// Represents a color glyph run. The IDWriteFactory2::TranslateColorGlyphRun 760 /// method returns an ordered collection of color glyph runs, which can be 761 /// layered on top of each other to produce a color representation of the 762 /// given base glyph run. 763 /// </summary> 764 struct DWRITE_COLOR_GLYPH_RUN 765 { 766 /// <summary> 767 /// Glyph run to render. 768 /// </summary> 769 DWRITE_GLYPH_RUN glyphRun; 770 771 /// <summary> 772 /// Optional glyph run description. 773 /// </summary> 774 DWRITE_GLYPH_RUN_DESCRIPTION* glyphRunDescription; 775 776 /// <summary> 777 /// Location at which to draw this glyph run. 778 /// </summary> 779 FLOAT baselineOriginX; 780 FLOAT baselineOriginY; 781 782 /// <summary> 783 /// Color to use for this layer, if any. This is the same color that 784 /// IDWriteFontFace2::GetPaletteEntries would return for the current 785 /// palette index if the paletteIndex member is less than 0xFFFF. If 786 /// the paletteIndex member is 0xFFFF then there is no associated 787 /// palette entry, this member is set to { 0, 0, 0, 0 }, and the client 788 /// should use the current foreground brush. 789 /// </summary> 790 DWRITE_COLOR_F runColor; 791 792 /// <summary> 793 /// Zero-based index of this layer's color entry in the current color 794 /// palette, or 0xFFFF if this layer is to be rendered using 795 /// the current foreground brush. 796 /// </summary> 797 UINT16 paletteIndex; 798 } 799 800 /// <summary> 801 /// Enumerator for an ordered collection of color glyph runs. 802 /// </summary> 803 mixin( uuid!(IDWriteColorGlyphRunEnumerator, "d31fbe17-f157-41a2-8d24-cb779e0560e8") ); 804 interface IDWriteColorGlyphRunEnumerator : IUnknown 805 { 806 /// <summary> 807 /// Advances to the first or next color run. The runs are enumerated 808 /// in order from back to front. 809 /// </summary> 810 /// <param name="hasRun">Receives TRUE if there is a current run or 811 /// FALSE if the end of the sequence has been reached.</param> 812 /// <returns> 813 /// Standard HRESULT error code. 814 /// </returns> 815 HRESULT MoveNext( 816 /*out*/ BOOL* hasRun 817 ); 818 819 /// <summary> 820 /// Gets the current color glyph run. 821 /// </summary> 822 /// <param name="colorGlyphRun">Receives a pointer to the color 823 /// glyph run. The pointer remains valid until the next call to 824 /// MoveNext or until the interface is released.</param> 825 /// <returns> 826 /// Standard HRESULT error code. An error is returned if there is 827 /// no current glyph run, i.e., if MoveNext has not yet been called 828 /// or if the end of the sequence has been reached. 829 /// </returns> 830 HRESULT GetCurrentRun( 831 /*out*/ const(DWRITE_COLOR_GLYPH_RUN*)* colorGlyphRun 832 ); 833 } 834 835 /// <summary> 836 /// The interface that represents text rendering settings for glyph rasterization and filtering. 837 /// </summary> 838 mixin( uuid!(IDWriteRenderingParams2, "F9D711C3-9777-40AE-87E8-3E5AF9BF0948") ); 839 interface IDWriteRenderingParams2 : IDWriteRenderingParams1 840 { 841 /// <summary> 842 /// Gets the grid fitting mode. 843 /// </summary> 844 DWRITE_GRID_FIT_MODE GetGridFitMode(); 845 } 846 847 /// <summary> 848 /// The root factory interface for all DWrite objects. 849 /// </summary> 850 mixin( uuid!(IDWriteFactory2, "0439fc60-ca44-4994-8dee-3a9af7b732ec") ); 851 interface IDWriteFactory2 : IDWriteFactory1 852 { 853 /// <summary> 854 /// Get the system-appropriate font fallback mapping list. 855 /// </summary> 856 /// <param name="fontFallback">The system fallback list.</param> 857 /// <returns> 858 /// Standard HRESULT error code. 859 /// </returns> 860 HRESULT GetSystemFontFallback( 861 /*out*/ IDWriteFontFallback* fontFallback 862 ); 863 864 /// <summary> 865 /// Create a custom font fallback builder. 866 /// </summary> 867 /// <param name="fontFallbackBuilder">Empty font fallback builder.</param> 868 /// <returns> 869 /// Standard HRESULT error code. 870 /// </returns> 871 HRESULT CreateFontFallbackBuilder( 872 /*out*/ IDWriteFontFallbackBuilder* fontFallbackBuilder 873 ); 874 875 /// <summary> 876 /// Translates a glyph run to a sequence of color glyph runs, which can be 877 /// rendered to produce a color representation of the original "base" run. 878 /// </summary> 879 /// <param name="baselineOriginX">Horizontal origin of the base glyph run in 880 /// pre-transform coordinates.</param> 881 /// <param name="baselineOriginY">Vertical origin of the base glyph run in 882 /// pre-transform coordinates.</param> 883 /// <param name="glyphRun">Pointer to the original "base" glyph run.</param> 884 /// <param name="glyphRunDescription">Optional glyph run description.</param> 885 /// <param name="measuringMode">Measuring mode, needed to compute the origins 886 /// of each glyph.</param> 887 /// <param name="worldToDeviceTransform">Matrix converting from the client's 888 /// coordinate space to device coordinates (pixels), i.e., the world transform 889 /// multiplied by any DPI scaling.</param> 890 /// <param name="colorPaletteIndex">Zero-based index of the color palette to use. 891 /// Valid indices are less than the number of palettes in the font, as returned 892 /// by IDWriteFontFace2::GetColorPaletteCount.</param> 893 /// <param name="colorLayers">If the function succeeds, receives a pointer 894 /// to an enumerator object that can be used to obtain the color glyph runs. 895 /// If the base run has no color glyphs, then the output pointer is NULL 896 /// and the method returns DWRITE_E_NOCOLOR.</param> 897 /// <returns> 898 /// Returns DWRITE_E_NOCOLOR if the font has no color information, the base 899 /// glyph run does not contain any color glyphs, or the specified color palette 900 /// index is out of range. In this case, the client should render the base glyph 901 /// run. Otherwise, returns a standard HRESULT error code. 902 /// </returns> 903 HRESULT TranslateColorGlyphRun( 904 FLOAT baselineOriginX, 905 FLOAT baselineOriginY, 906 const(DWRITE_GLYPH_RUN)* glyphRun, 907 const(DWRITE_GLYPH_RUN_DESCRIPTION)* glyphRunDescription, 908 DWRITE_MEASURING_MODE measuringMode, 909 const(DWRITE_MATRIX)* worldToDeviceTransform, 910 UINT32 colorPaletteIndex, 911 /*out*/ IDWriteColorGlyphRunEnumerator* colorLayers 912 ); 913 914 /// <summary> 915 /// Creates a rendering parameters object with the specified properties. 916 /// </summary> 917 /// <param name="gamma">The gamma value used for gamma correction, which must be greater than zero and cannot exceed 256.</param> 918 /// <param name="enhancedContrast">The amount of contrast enhancement, zero or greater.</param> 919 /// <param name="clearTypeLevel">The degree of ClearType level, from 0.0f (no ClearType) to 1.0f (full ClearType).</param> 920 /// <param name="pixelGeometry">The geometry of a device pixel.</param> 921 /// <param name="renderingMode">Method of rendering glyphs. In most cases, this should be DWRITE_RENDERING_MODE_DEFAULT to automatically use an appropriate mode.</param> 922 /// <param name="gridFitMode">How to grid fit glyph outlines. In most cases, this should be DWRITE_GRID_FIT_DEFAULT to automatically choose an appropriate mode.</param> 923 /// <param name="renderingParams">Holds the newly created rendering parameters object, or NULL in case of failure.</param> 924 /// <returns> 925 /// Standard HRESULT error code. 926 /// </returns> 927 HRESULT CreateCustomRenderingParams( 928 FLOAT gamma, 929 FLOAT enhancedContrast, 930 FLOAT grayscaleEnhancedContrast, 931 FLOAT clearTypeLevel, 932 DWRITE_PIXEL_GEOMETRY pixelGeometry, 933 DWRITE_RENDERING_MODE renderingMode, 934 DWRITE_GRID_FIT_MODE gridFitMode, 935 /*out*/ IDWriteRenderingParams2* renderingParams 936 ); 937 938 //using IDWriteFactory::CreateCustomRenderingParams; 939 //using IDWriteFactory1::CreateCustomRenderingParams; 940 941 /// <summary> 942 /// Creates a glyph run analysis object, which encapsulates information 943 /// used to render a glyph run. 944 /// </summary> 945 /// <param name="glyphRun">Structure specifying the properties of the glyph run.</param> 946 /// <param name="transform">Optional transform applied to the glyphs and their positions. This transform is applied after the 947 /// scaling specified the emSize and pixelsPerDip.</param> 948 /// <param name="renderingMode">Specifies the rendering mode, which must be one of the raster rendering modes (i.e., not default 949 /// and not outline).</param> 950 /// <param name="measuringMode">Specifies the method to measure glyphs.</param> 951 /// <param name="gridFitMode">How to grid-fit glyph outlines. This must be non-default.</param> 952 /// <param name="baselineOriginX">Horizontal position of the baseline origin, in DIPs.</param> 953 /// <param name="baselineOriginY">Vertical position of the baseline origin, in DIPs.</param> 954 /// <param name="glyphRunAnalysis">Receives a pointer to the newly created object.</param> 955 /// <returns> 956 /// Standard HRESULT error code. 957 /// </returns> 958 HRESULT CreateGlyphRunAnalysis( 959 const(DWRITE_GLYPH_RUN)* glyphRun, 960 const(DWRITE_MATRIX)* transform, 961 DWRITE_RENDERING_MODE renderingMode, 962 DWRITE_MEASURING_MODE measuringMode, 963 DWRITE_GRID_FIT_MODE gridFitMode, 964 DWRITE_TEXT_ANTIALIAS_MODE antialiasMode, 965 FLOAT baselineOriginX, 966 FLOAT baselineOriginY, 967 /*out*/ IDWriteGlyphRunAnalysis* glyphRunAnalysis 968 ); 969 970 //using IDWriteFactory::CreateGlyphRunAnalysis; 971 }